﻿<!DOCTYPE HTML>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <title>登陆</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <link href="../css/H-ui.min.css" rel="stylesheet" type="text/css"/>
    <link href="../css/H-ui.css" rel="stylesheet" type="text/css"/>
    <link rel="stylesheet" type="text/css" href="../css/font-awesome.min.css" />
    <link rel="stylesheet" type="text/css" href="../css/style.css" />
    <script src='../js/jquery-1.11.2.min.js'></script>
    <script type="text/javascript" src="../js/H-ui.min.js"></script>
    <script type="text/javascript" src="../js/layer/2.4/layer.js"></script>
    <script type="text/javascript" src="../js/postJson.js"></script>
    <script type="text/javascript" src="../js/root.js"></script>

</head>
<body>
<div class="header">
    <h1>云上飘</h1>
</div>
<div class="loginWraper">
    <div id="loginform" class="loginBox">
        <form class="form form-horizontal" action="" method="post">
            <div class="row cl">
                <label class="form-label col-xs-3"><i class="fa fa-user ft34"></i></label>
                <div class="formControls col-xs-8">
                    <input  id="account" name="account" type="text" placeholder="账户" class="input-text size-L">
                    <span class="error_text"><i class="fa fa-user"></i>用户名不存在</span>
                </div>
            </div>

            <div class="row cl">
                <label class="form-label col-xs-3"><i class="fa fa-unlock-alt ft34"></i></label>
                <div class="formControls col-xs-8">
                    <input  id="password" name="password" type="password" placeholder="密码" class="input-text size-L">
                    <span class="error_text"><i class="Hui-iconfont">&#xe6dd;</i>密码错误</span>
                </div>
            </div>

            <div class="row cl">
                <div class="formControls col-xs-8 col-xs-offset-3">
                    <div  class="btn btn-success radius size-L" id="loginBtn">登录</div>
                    <div name="" class="btn btn-default radius size-L">取消</div>
                </div>
            </div>
        </form>
    </div>
</div>
<script>

    $(function(){
        $("#loginBtn").click(function(){
            var account = $("#account").val();
            var password = $("#password").val();
            if(!account|| !password)
            {
                layer.msg("请填写完整信息！")
                return;
            }
            var dataCollect=$('.form').serialize();
            dataCollect= decodeURIComponent(dataCollect,true);//防止中文乱码
            var jsondata=strJSON.formToJson(dataCollect);//转化为json
            var url = "/sys/dologin";
            $.ajax({
                url:url,
                contentType:"application/json",
                data:jsondata,
                type:"post",
                dataType:'json',
                success:function(data){
                    if(data.success==true){
                        location.href="/logInController/index";
                    }else{
                        layer.msg(data.errorMessage)
                    }
                },
                error:function(XMLHttpRequest,textStatus,errorThrown){
                    var XmlStatus = XMLHttpRequest.status
//                         console.log(XMLHttpRequest.status)
                    if(XmlStatus==401){
                        alert(XmlError.error401)
                        parent.window.location.href = "login"
                    }
                    if(XmlStatus==403){
                        alert(XmlError.error403)
                    }
                }
            })
        });

        //读取配置文件 系统名称
        function urlName() {
            var url = "/sys/urlName";

            $.ajax({
                url: url,
                type: "get",
                async: false,
                dataType: 'json',
                success: function (msg) {
                    if(msg.success==true){
                        $('title').text(msg.data)
                        $('h1').text(msg.data)
                    }else{
                        parent.layer.msg(msg.data,{icon:2,time:5000});
                    }
                },
                error:function(XMLHttpRequest,textStatus,errorThrown){
                    var XmlStatus = XMLHttpRequest.status
//                         console.log(XMLHttpRequest.status)
                    if(XmlStatus==401){
                        alert(XmlError.error401)
                        parent.window.location.href = "login"
                    }
                    if(XmlStatus==403){
                        alert(XmlError.error403)
                    }
                }
            });

        };
        // urlName();

        $(document).keydown(function(e){
            if (e.keyCode == 13) {
                var account = $("#account").val();
                var password = $("#password").val();
                if(!account|| !password)
                {
                    layer.msg("请填写完整信息！")
                    return;
                }
                var dataCollect=$('.form').serialize();
                dataCollect= decodeURIComponent(dataCollect,true);//防止中文乱码
                var jsondata=strJSON.formToJson(dataCollect);//转化为json
                var url = "/sys/dologin";
                $.ajax({
                    url:url,
                    contentType:"application/json",
                    data:jsondata,
                    type:"post",
                    dataType:'json',
                    success:function(data){
                        if(data.success==true){
                            location.href="/logInController/index";
                        }else{
                            layer.msg(data.errorMessage)
                        }
                    },
                    error:function(XMLHttpRequest,textStatus,errorThrown){
                        var XmlStatus = XMLHttpRequest.status
//                         console.log(XMLHttpRequest.status)
                        if(XmlStatus==401){
                            alert(XmlError.error401)
                            parent.window.location.href = "login"
                        }
                        if(XmlStatus==403){
                            alert(XmlError.error403)
                        }
                    }
                })
            }
        })
    })
</script>
</body>
</html>